package jwt.util;

import java.util.*;

public class test {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

        StudentVo vo = testTMath(new StudentVo());
        System.out.println(vo.getName()+vo.getClassName());
    }
    private static <T>T testTMath(T tClass) throws InstantiationException, IllegalAccessException {

        Object put = null;
        if(tClass instanceof String){
            System.out.println(tClass);
            put = (String)tClass ;
        }else if(tClass instanceof HashMap){
            ((HashMap) tClass).put("1", "3");
            return tClass;
        }else if(tClass instanceof StudentVo){
            ((StudentVo) tClass).setClassName("一年级一班");
            ((StudentVo) tClass).setName("王文强");
        }
        
        return tClass;
    }

    private static void testSubString(){
        String text = "收到回复水电费时代峰峻黄老师，方式到家了，时代峰峻啦。地方吉林省ssdjslf ,djjsjdlfsj";
        Map<Integer,String> map = new HashMap<>();
        map.put(0,"<speak><action>xxx</aciton></speak>");
        map.put(5,"<speak><action>yyy</aciton></speak>");
        map.put(10,"<speak><action>hahah</aciton></speak>");
        map.put(18,"<speak><action>hahah</aciton></speak>");
        map.put(29,"<speak><action>kkk</aciton></speak>");
        map.put(37,"<speak><action>xjsuj</aciton></speak>");
        map.put(50,"<speak><action>jdjsj</aciton></speak>");
        StringBuilder stringBuilder = new StringBuilder();
        Set<Integer> integerSet = map.keySet();
        List<Integer> list = integerSet.stream().sorted(Comparator.comparingInt(Integer::intValue)).toList();
        for (int i = 0; i < list.size(); i++) {
            //判断是否到结尾
            if(i == (list.size()-1)){
                String substring = text.substring(list.get(i));
                stringBuilder.append(map.get(list.get(i))).append(substring);
                break;
            }
            String substring = text.substring(list.get(i), list.get(i + 1));
            stringBuilder.append(map.get(list.get(i))).append(substring);

        }
        System.out.println("最终字符串为："+stringBuilder);
    }
}
